package kylin.controller.admin;

import java.util.HashMap;
import java.util.Map;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping(value="manage/system")
public class SystemController {

	@RequestMapping("ajaxGetMemory")
	public @ResponseBody Map<String, Double> ajaxGetMemory(){
		long unit = 1024 * 1024;
		double total = Runtime.getRuntime().totalMemory() / unit;
		double max = Runtime.getRuntime().maxMemory() / unit;
		double free = Runtime.getRuntime().freeMemory() / unit;
		double valid = max + free - total;
		
		Map<String, Double> map = new HashMap<String,Double>();
		map.put("total", total);
		map.put("max", max);
		map.put("free", free);
		map.put("valid", valid);
		
		return map;
	}
	
}
